package castledefense.logic;

public class Dot {
	private int time;
	private int howOften;
	private double damagePerTick;
	private int damageType;
	private Targetable target;

	public Dot(int time, int howOften, double damagePerTick, int damageType,
			Targetable target) {
		this.time = time;
		this.howOften = howOften;
		this.damagePerTick = damagePerTick;
		this.damageType = damageType;
		this.target = target;
	}

	/**
	 * boolean update(int deltaTime) return true if effect should be removed
	 */
	public final boolean update(int deltaTime) {
		final int tmp = time / howOften;
		time = (time - deltaTime);
		if (tmp != (time / howOften)) {
			target.decreaseHealth(damagePerTick, damageType);
		}
		if (time < 0) {
			return true;
		}
		return false;
	}

	public int getTime() {
		return time;
	}

}
